#include "themeitem.h"
#include "ui_themeitem.h"

ThemeItem::ThemeItem(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::ThemeItem)
{
    ui->setupUi(this);
    setAttribute(Qt::WA_StyledBackground);
}

ThemeItem::~ThemeItem()
{
    delete ui;
}

void ThemeItem::setTheme(Theme theme)
{
    this->theme = theme;
    this->ui->name->setText(theme.name);
    QPixmap pic = QPixmap(theme.backgroundPath);
    pic = pic.scaled(this->ui->img->size());      // 适应label缩放
    this->ui->img->setPixmap(pic);
}

void ThemeItem::on_pushButton_clicked()
{
    emit setCurrentTheme(this->theme);
}

